package com.boot.interceptor;

import com.boot.result.Result;
import com.boot.result.ResultCodeNum;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    public Result handleBusinessException(BusinessException e) {
        return Result.build(e.getMessage(), e.getResultCodeNum());
    }

    @ExceptionHandler(Exception.class)
    public Result handException(Exception e) {
        e.printStackTrace();
        return Result.build(null, ResultCodeNum.SYSTEM_ERROR);
    }

}
